<%
/**
 *  edit 玉米试验编辑
 * 
 * @author  李荣华
 * @version v1.0
 * @date    2018-10-16
 * @since   JSP 2.3.1
 */
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="at" uri="http://www.jketing.com/at"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>玉米试验</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta content="no-cache" http-equiv="Pragma"/>
	<meta content="no-cache" http-equiv="Cache-Control"/>
	<meta content="0" http-equiv="Expires"/>
	<meta name="GENERATOR" content="MSHTML 8.00.6001.18854"/>
	<link rel="stylesheet" type="text/css" href="<at:url css="edit.css"/>" />
	<link rel="stylesheet" type="text/css" href="<at:url css="banner_button.css"/>" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/css/validationEngine.jquery.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/css/template.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/select.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common/My97DatePicker/WdatePicker.js"></script>	
	<script type="text/javascript" src="<at:url js="edit.js"/>"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/languages/jquery.validationEngine-cn.js" charset="utf-8"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/jquery.validationEngine.js" charset="utf-8"></script>
	<script type="text/javascript">
	

	/**
	 * 重置操作
	 */
	function reset() {
		document.getElementById("webForm").reset();
	}	
	
	/**
	 * 返回列表
	 */
	function ret(){				
		if(window.confirm('数据没保存，你确定要返回列表吗？')){
			window.history.back(-1);//因要删除进入更新编辑页时保存在session中的查询数据，故不能使用js退回
		}
	}
	
	/**
	 * 提交数据
	 */
	function submit() {
		/* if($("#webForm").validationEngine('validate')){
			$("#webForm").submit();
		} */
		refreshJson();
		$("#webForm").submit();
	}

	/**
	 * 照片上传操作 
	 */
	function init(){
		var upload = $('#uploadPhoto'), interval;
		new AjaxUpload(upload, {
			action: 'adjunct!upImage', 
			name: 'file',
			onSubmit : function(file, ext){
				// change button text, when user selects file			
				upload.text('<s:text name="js.common.uploadPhoto"></s:text>');
				// If you want to allow uploading only 1 file at time,
				// you can disable upload button
				this.disable();
				
				// Uploding -> Uploading. -> Uploading...
				interval = window.setInterval(function(){
					var text = upload.text();
					if (text.length < 10){
						upload.text(text + '.');					
					} else {
						upload.text('<s:text name="js.common.uploadPhoto"></s:text>');				
					}
				}, 200);
			},
			onComplete: function(file, response){
				var json = eval('(' + response + ')');
				window.clearInterval(interval);
				document.getElementById("uploadPhoto").value = json.id;
				//$("#webForm").validate().element($("#photo"));
				document.getElementById("uploadPhoto").innerHTML = "<img width='200' height='127' src='adjunct!getImage?af.id=" + json.id + "' alt='上传照片' />";	
				// enable upload button
				this.enable();				
			}
		});
	}
	
	function createTableHeader(){
		var iTable=document.getElementById("testTable");//获取table标签
		
		do{
			iTable.deleteRow(0);
		}while(iTable.rows.length!=0);
		
		var tr=document.createElement("tr");
		var td=document.createElement('td');
		td.setAttribute('colspan', '22');
		td.setAttribute('align', 'center');
		td.innerHTML='<div style="margin-top: 5px;margin-bottom: 5px">玉米试验考种表</div>';
		tr.appendChild(td);
		iTable.appendChild(tr);//添加tr
		
		tr=document.createElement("tr");//标题行
		iTable.appendChild(tr);//添加tr
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<div style="margin-top: 5px;margin-bottom: 5px"><nobr>品种名称</nobr></div>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '3%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>重复</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>穗长(cm)</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>穗粗(cm)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>穗行数</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>行粒数</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '3%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>粒色</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '3%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>粒型</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '3%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>穗型</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '3%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>轴色</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>穗腐病(%)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>粒腐病(%)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>秃尖度(cm)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>千粒重(g)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>鲜包重(kg)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>干包重(kg)</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>干粒重(kg)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>折籽率(%)</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>出籽率(%)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>小区鲜重(kg)</nobr>';
		tr.appendChild(td);
		
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>小区产量(kg)</nobr>';
		tr.appendChild(td);
	
		td=document.createElement('td');
		td.setAttribute('width', '5%');
		td.setAttribute('align', 'center');
		td.innerHTML='<nobr>折合亩产(kg)</nobr>';
		tr.appendChild(td);
	}
	

	
	function createEmptyTable()
	{
		var varietyNumber = document.getElementById("objectVarietyNumber");
		var repetitionNumber = document.getElementById("objectRepetitionNumber");
		if(isNaN(varietyNumber.value)){
			alert("请输入正整数！");
			varietyNumber.focus();
			return;
		}
		
		if(isNaN(repetitionNumber.value)){
			alert("请输入正整数！");
			repetitionNumber.focus();
			return;
		}
		
		var number = parseInt(varietyNumber.value);
		var repetNum = parseInt(repetitionNumber.value);
		
		if(isNaN(number)) number = 1;
		if(isNaN(repetNum)) repetNum = 1;
		
		<c:if test="${entity.id == null }">
			createTableHeader();
		</c:if>
		
		var iTable=document.getElementById("testTable");//获取table标签		
		var i=0;
		<c:if test="${entity.id != null }">
			repetNum = parseInt("${entity.repetitionNumber}");
			var lastIndex = (iTable.rows.length-2)/repetNum;
			var rowNum = number - lastIndex;
			if(rowNum < 0){
				var removeRowNum = Math.abs(rowNum);
				for(k=0;k<removeRowNum;k++){
					for(n=0;n<repetNum;n++){
						iTable.deleteRow(iTable.rows.length-1);
					}
				}
				return;
			}else{
				i = lastIndex;
			}
		</c:if>
		for(;i<number;i++){
			for(j=1;j<=repetNum;j++){
				tr=document.createElement("tr");//品种行
				iTable.appendChild(tr);//添加tr
				if(j==1){
					td=document.createElement('td');
					td.setAttribute('width', '5%');
					td.setAttribute('align', 'center');
					td.setAttribute('rowspan', '' + repetNum);
					td.innerHTML='<input type="text" id="varietyName' + i + '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
					tr.appendChild(td);
				}
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>' + j + '</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeLength'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeWide'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeRowNumber'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="rowGrainNumber'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainColor'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainType'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeType'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="axialColour'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeRot'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainRot'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="alopeciaAcuity'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="thousandGrainWeight'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="freshPackageWeight'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="dryPackageWeight'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="dryGrainWeight'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="plotFreshWeight'+ i + j +'" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
			}
			//var tr=document.createElement("tr");
		}
	}
	

	
	function refreshJson(){
    	var varieties = document.getElementById("varietiesJson");
    	var number = parseInt(document.getElementById("objectVarietyNumber").value);
    	var repetNum = parseInt(document.getElementById("objectRepetitionNumber").value);
    	var varietiesJson = '[';
    	for(var i=0;i<number;i++)
    	{
    		varietiesJson += '{"name":"'
    				 + document.getElementById("varietyName" + i).value
    				 + '","repetitions":[';
    		for (var j=1;j<=repetNum;j++)
    	    {
    			varietiesJson += '{"id":"'
    				 + document.getElementById("varietyName" + i).value + i + j
    				 + '","spikeLength":"'
        			 + document.getElementById("spikeLength" + i + j).value
    				 + '","spikeWide":"'
    				 + document.getElementById("spikeWide" + i + j).value
    				 + '","spikeRowNumber":"'
    				 + document.getElementById("spikeRowNumber" + i + j).value
    				 + '","rowGrainNumber":"'
    				 + document.getElementById("rowGrainNumber" + i + j).value
    				 + '","grainColor":"'
    				 + document.getElementById("grainColor" + i + j).value
    				 + '","grainType":"'
    				 + document.getElementById("grainType" + i + j).value
    				 + '","spikeType":"'
    				 + document.getElementById("spikeType" + i + j).value
    				 + '","axialColour":"'
    				 + document.getElementById("axialColour" + i + j).value
    				 + '","spikeRot":"'
    				 + document.getElementById("spikeRot" + i + j).value
    				 + '","grainRot":"'
    				 + document.getElementById("grainRot" + i + j).value
    				 + '","alopeciaAcuity":"'
    				 + document.getElementById("alopeciaAcuity" + i + j).value
    				 + '","thousandGrainWeight":"'
    				 + document.getElementById("thousandGrainWeight" + i + j).value
    				 + '","freshPackageWeight":"'
    				 + document.getElementById("freshPackageWeight" + i + j).value
    				 + '","dryPackageWeight":"'
    				 + document.getElementById("dryPackageWeight" + i + j).value
    				 + '","dryGrainWeight":"'
    				 + document.getElementById("dryGrainWeight" + i + j).value
    				 + '","plotFreshWeight":"'
    				 + document.getElementById("plotFreshWeight" + i + j).value
    				 + '"}';
    			if(j<repetNum) varietiesJson += ',';
    	    }
    		varietiesJson += ']}';
    		if(i<number-1) varietiesJson += ',';
    	}
    	
    	varietiesJson += ']';
	    varieties.value = varietiesJson;				
	}
	
	<c:if test="${entity.id != null }">
	function createTable(){
		var obj = ${varietiesJson};
		createTableHeader();
		var iTable=document.getElementById("testTable");//获取table标签
		for(i=0;i<obj.length;i++){
			for(j=0;j<obj[i].repetitions.length;j++){
				tr=document.createElement("tr");//品种行
				iTable.appendChild(tr);//添加tr
				var index = j+1;
				if(j==0){
					td=document.createElement('td');
					td.setAttribute('width', '5%');
					td.setAttribute('align', 'center');
					td.setAttribute('rowspan', '3');
					td.innerHTML='<input type="text" id="varietyName'
											+ i +'" '
											+ 'value="'
											+ obj[i].name
											+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
					tr.appendChild(td);
				}
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>' + index + '</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeLength'+ i + index
											+'" value="'
											+ obj[i].repetitions[j].spikeLength
											+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeWide'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].spikeWide
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeRowNumber'+ i + index
									+'" value="'
									+ obj[i].repetitions[j].spikeRowNumber
									+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="rowGrainNumber'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].rowGrainNumber
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainColor'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].grainColor
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainType'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].grainType
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeType'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].spikeType
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '3%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="axialColour'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].axialColour
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="spikeRot'+ i + index
									+'" value="'
									+ obj[i].repetitions[j].spikeRot
									+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="grainRot'+ i + index
									+'" value="'
									+ obj[i].repetitions[j].grainRot
									+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="alopeciaAcuity'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].alopeciaAcuity
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="thousandGrainWeight'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].thousandGrainWeight
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="freshPackageWeight'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].freshPackageWeight
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="dryPackageWeight'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].dryPackageWeight
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="dryGrainWeight'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].dryGrainWeight
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<input type="text" id="plotFreshWeight'+ i + index
										+'" value="'
										+ obj[i].repetitions[j].plotFreshWeight
										+ '" style="margin-top: 1px;margin-bottom: 1px;width: 98%;border: 0px;outline:none;text-align: center;" />';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
				
				td=document.createElement('td');
				td.setAttribute('width', '5%');
				td.setAttribute('align', 'center');
				td.innerHTML='<nobr>0.0</nobr>';
				tr.appendChild(td);
			}
		}
	}
	</c:if>
	

		
	/**
	 * 加载照片
	 */
	/*$(document).ready(function(){
		init();
	});*/
	

	
	/**
	 * validation-engine 表单验证 
	 */
	jQuery(document).ready(function(){
		if('${varietiesJson}'!=''){
			createTable();
		}
    });
	
	</script>
	<c:set value="${pageContext.request.contextPath}/maizeExperiment/save" var="url"></c:set>
	<c:if test="${entity.id != null }">
		<c:set value="${pageContext.request.contextPath}/maizeExperiment/update/${entity.id}" var="url"></c:set>
	</c:if>
</head>
<body>		
	<form:form action="${url}" method="POST" enctype="multipart/form-data"
		modelAttribute="entity" class="form-style" id="webForm" name="webForm">
		<c:if test="${entity.id!=null}">
			<form:hidden path="id"/>
			<input type="hidden" name="_method" value="PUT"/>
		</c:if>
		<input type="hidden" name="page" value="${page}"/>	
		<input type="hidden" name="order" value="${order}" />
		<input type="hidden" id="varietiesJson" name="varietiesJson" value="${varietiesJson}"/>		
		<!-- 按钮行 -->
		<div class="edit_top">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="4" height="24" id="kj2z03"></td>
					<td class="biao3_xia">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td height="24" class="biao4_zhong">
									<div id="nav_01">
										<ul>
											<li><a href="#" onclick="ret();">返回</a></li>
											<li><a href="#" onclick="submit();">提交</a></li>
										</ul>
									</div>
								</td>
							</tr>
						</table>
					</td>
					<td width="4" height="24" id="kj2y03"></td>
				</tr>
			</table>
		</div>
		<div class="edit_main">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							rules="groups">
							<tr>
								<td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td align="right" valign="middle" class="font_1">
												<nobr>名称</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<form:input path="name" class="validate[required]" id="objectName" style="width:90%"/>
												<font color="red">*</font>		
											</td>
																															
										</tr>
									</table>
								</td>
								<td width="50%" height="100%" class="biantiao_you" rowspan="13" colspan="2">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="100%" align="center" valign="middle" class="font_1" >
												<c:choose>
													<c:when test="${entity.id!=null}">
														<img src="${pageContext.request.contextPath}/maizeExperiment/getImage/${entity.id}"  width="320px" height="160px" alt="照片" />
												   	</c:when> 
												   	<c:otherwise>
												   		<img src="${pageContext.request.contextPath}/res/image/organ_default.jpg" width="320px" height="160px" alt="照片" />
												   	</c:otherwise>  
												</c:choose>
											</td>																				
										</tr>
									</table>
								</td>													
							</tr>																
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>地点</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<form:input path="locale" class="validate[required]" id="objectLocale" style="width:90%"/>
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>海拔</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<form:input path="altitude" class="validate[required]" id="objectAltitude" style="width:90%"/>
												<font color="red">*</font>															
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>品种数量</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<form:input path="varietyNumber" 
													class="validate[required]" 
													id="objectVarietyNumber"
													onchange="createEmptyTable();" 
													style="width:90%"/>
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>重复数</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<input  class="validate[required]" 
															 style="width:90%"
															  id="objectRepetitionNumber"
															  name="repetitionNumber" 
															  <c:if test="${entity.id != null }">
																disabled="disabled"
															</c:if>
															  value="${entity.repetitionNumber}"
															  onchange="createEmptyTable();" />
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>对照</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<form:input path="contrast" 
													class="validate[required]" 
													id="objectContrast"
													style="width:90%"/>
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>播种日期</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="sowingTime" 
													class="validate[required]" 
													id="objectSowingTime" 
													readonly="readonly"
													onfocus="WdatePicker({isShowWeek:true});"
													style="width:90%"/>
													<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>第一次施肥</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="firstFertilizationTtime" 
													class="validate[required]" 
													id="objectFirstFertilizationTtime" 
													readonly="readonly"
													onfocus="WdatePicker({isShowWeek:true});"
													style="width:90%"/>
													<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>试验照片</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<input type="file" name="file" size="90%" style="width:90%"/>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" class="font_1">
												<nobr>第二次施肥</nobr>
											</td>																				
										</tr>
									</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="secondFertilizationTtime" 
													class="validate[required]" 
													id="objectSecondFertilizationTtime" 
													readonly="readonly"
													onfocus="WdatePicker({isShowWeek:true});"
													style="width:90%"/>
													<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>收获日期</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="harvestDate" 
													class="validate[required]" 
													id="objectHarvestDate" 
													readonly="readonly"
													onfocus="WdatePicker({isShowWeek:true});"
													style="width:90%"/>
													<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	

							<!-- 行分割线 -->
							<tr>
								<td colspan="4">
									<div style="height: 1;" class="biaotiao_xia"></div>
								</td>
							</tr>
							<tr>	
								<td width="20%" height="30" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>试验介绍</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="30" colspan="4">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:textarea path="describe" rows="5" cols="79" style="width:96.5%"/>
											</td>
										</tr>
									</table>
								</td>	
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td colspan="4">
									<div style="height: 1;" class="biaotiao_xia"></div>
								</td>
							</tr>
							<tr>
								<td colspan="4">
									<table id="testTable" width="100%" border="1"  style="border-collapse:collapse;" >
										<tr>
											<td colspan="22" align="center">
												<div style="margin-top: 5px;margin-bottom: 5px">玉米试验考种表</div>
											</td>
										</tr>
										<tr>		
											<td width="5%" align="center">
												<div style="margin-top: 5px;margin-bottom: 5px"><nobr>品种名称</nobr></div>
											</td>
											<td width="3%" align="center">
												<nobr>重复</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>穗长(cm)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>穗粗(cm)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>穗行数</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>行粒数</nobr>
											</td>
											<td width="3%" align="center">
												<nobr>粒色</nobr>
											</td>
											<td width="3%" align="center">
												<nobr>粒型</nobr>
											</td>
											<td width="3%" align="center">
												<nobr>穗型</nobr>
											</td>
											<td width="3%" align="center">
												<nobr>轴色</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>穗腐病(%)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>粒腐病(%)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>秃尖度(cm)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>千粒重(g)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>鲜包重(kg)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>干包重(kg)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>干粒重(kg)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>折籽率(%)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>出籽率(%)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>小区鲜重(kg)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>小区产量(kg)</nobr>
											</td>
											<td width="5%" align="center">
												<nobr>折合亩产(kg)</nobr>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</form:form>
</body>
</html>
